package com.qf.controller.advice;/*
 *徐韬
 *2021/10/25
 *21:16
 */

import com.qf.dto.R;
import com.qf.exceptions.MybaseExecption;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;
import sun.nio.cs.ext.MS874;

@ControllerAdvice
@ResponseBody
public class MyExecptionadvice {
    @ExceptionHandler(MybaseExecption.class)
    public R procrssMyExecption(MybaseExecption execption) {
        Integer code = execption.getCode();
        String msg = execption.getMessage();
        return R.setError(code, msg, null);//返回前端R  调用者就不会收到异常了 会收到一个数据

    }
    @ExceptionHandler(Exception.class)
    public R procrssMyExecption(Exception execption) {
        execption.printStackTrace();
        return R.setError(null);//返回前端R  调用者就不会收到异常了 会收到一个数据

    }

}
